import threading
import time
# sampleOne
'''需求：多个线程删除列表中的最后一个元素并删除'''
L=[1,3,45,65,76,32,3254]
def pri():
    while 1:
        a = L[-1]
        print(a)
        time.sleep(2)
        L.remove(a) # 按值来删除
        # L.pop(-1) # 按照索引删除
t1=threading.Thread(target=pri,args=())
t1.start()
t2=threading.Thread(target=pri,args=())
t2.start()

# # sampleTwo
import queue
'''队列queue、是一种数据结构线程使用队列、数据是安全的'''
Li=[]
q=queue.Queue()# FIFO
# # q =queue.LifoQueue()# LIFO
# q =queue.PriorityQueue(4) # 优先级s
q.put([4,234])
q.put_nowait([2,"hello"])
q.put([3,{"name","alex"}])
q.put([5,{"gendle":"女"}])
# q.put(78,block=False) # 队列已满时报错
# q.put_nowait(78) # 队列已满时报错
while 1:
    # data=q.get()
    data = q.get(block=False)
    # data =q.get_nowait()  # 为空时报错
    print(data)
    # print(q.qsize())
    # print(q.empty())
    # print(q.full())
    # print(data[1])
    time.sleep(1)
    print("----------")